/*
 * QuadCyber.java
 *
 * Created on June 15, 2005, 2:46 PM
 */

package aa.application.AdaptiveQuad;

import aa.core.CyberOrg;
import aa.core.Contract;
import aa.core.ActorName;
import aa.core.Platform;

import java.util.Random;
import java.util.LinkedList;



/**
 *
 * @author  xinghuizhao
 */
public class QuadCyber extends CyberOrg{
    
    /** Creates a new instance of QuadCyber */
    public QuadCyber() {
    }
    
    public QuadCyber(Long p_longTicks, Long p_longTicksRate, Long p_longECash, String p_strFacili, Object[] objaAgs){
        super(p_longTicks,p_longTicksRate,p_longECash,p_strFacili,objaAgs);
    }
    
    
    
    public void resourceAlloc(ActorName p_anNeedResource, long p_iRate, long p_iRes){
       
        long originalRes = m_pPlatform.returnRes(p_anNeedResource);
        
        
        m_lTicksRate += originalRes;
        
        long rateAssign = p_iRate;
        m_lTicksRate -= rateAssign;
        
        
        
        //allocate the resource
        //comment for debug
        //m_pPlatform.resAlloc(p_anNeedResource, rateAssign, totalAssign);
        
    }
    
    
    /*Nov16: trying to make cyberorg extendable. this main method is just for testing*/
    public static void main(String[] args){
        
        Integer myPort = new Integer(8070);
        
        
        //View myView = new View(myPort);
        
        //Platform pPlatform=new Platform(myView,myPort);
        
        Platform pPlatform = new Platform(null,myPort);
        
        pPlatform.start();
        
        Object[] nullobja={};
        
        //QuadCyber qc= new QuadCyber();
        
        //CyberOrg co = qc;
        
        Object[] cyberAgs = new Object[5];
        
        cyberAgs[0]= new Long(9000);
        cyberAgs[1]=new Long(1000);
        cyberAgs[2]=new Long(80);
        cyberAgs[3]= "aa.core.FacilitatorActor";
        cyberAgs[4]= nullobja;
        
        QuadCyber fibCyber=(QuadCyber)pPlatform.createCyberOrg("aa.application.AdaptiveQuad.QuadCyber",cyberAgs);
        
        
        System.out.println(fibCyber.getClass());
    }
    
}
